package springboot.demo.shiro.controller;

import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authc.AuthenticationException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import springboot.demo.shiro.entity.dto.ResultDto;

/**
 * <p>Project: springboot-demo </p>
 * 
 * <p>Function:  </p>
 * 
 * <p>Description:  </p>
 * 
 * @author weiqiang.li
 * 
 * @date 2018/11/24
 * 
 * @version 1.0
 */
@Slf4j
@RestControllerAdvice
public class ExceptionController {

    @ExceptionHandler(AuthenticationException.class)
    public ResultDto<?> handleShiroException(Exception ex) {
        log.error("授权失败：{}", ex.getMessage());
        return ResultDto.builder().success(false).msg(ex.getMessage()).build();
    }
}
